﻿using System;
using System.Collections.Generic;
using System.Text;
using AspNetCs.IDAL;
using AspNetCs.DALFactory;
using AspNetCs.Common;
using AspNetCs.Config;
namespace AspNetCs.Bll
{
    public class Vote
    {
        private IVote vote = Conn.CreateVote();




        #region IVote 成员

        public AspNetCs.Model.Vote_Model GetModel(System.Data.DataRow dr)
        {
            return vote.GetModel(dr);
        }

        public AspNetCs.Model.Vote_Model GetModel(int id)
        {
            return vote.GetModel(id);
        }

        public int Add(AspNetCs.Model.Vote_Model model)
        {
            if (model == null) return -1;
            return vote.Add(model);
        }

        public int Update(AspNetCs.Model.Vote_Model model)
        {
            if (model == null) return -1;
            return vote.Update(model);
        }

        public int Del(int id)
        {
            if (id <= 0) return -1;
            return vote.Del(id);
        }
        /// <summary>
        /// 删除所有 
        /// </summary>
        /// <param name="filter"></param>
        /// <returns></returns>
        public int delAll(string filter)
        {

            string[] SpStr = StringHelper.SplitString(filter, ",");
            int result = -1;
            try
            {
                foreach (string str in SpStr)
                {
                    if (str != "")
                    {
                        result = Del(StringHelper.isNumber_int(str));
                    }
                }
            }
            catch(Exception Ex){
                new CustomException(Ex);
            }
            return result;
        }


        public System.Data.DataTable GetDataTable(string filter)
        {
            return vote.GetDataTable(filter);
        }

        #endregion
    }
}
